<template>
    <ul v-infinite-scroll="loadMore"
        infinite-scroll-disabled="loading"
        infinite-scroll-distance="10" class="f-mb80">
        <li v-for="item in list" :key="item.index">
            <h3 class="f-tal">{{item.typename}}</h3>
            <div v-if="item.indextype==='gamelist'">
            <ul class="list">
                <li v-for="(idx,ind) in item.data" :key="ind" class="f-dfc">
                <img :src="idx.micon" class="bg">
                <div class="f-fx1" @click="link(idx.gameid)">
                    <p>{{idx.name}}</p>
                    <p class="f-666 f-fs12">{{idx.typename}}｜{{idx.adsize}}</p>
                    <p class="f-e85 f-fs12">首充{{idx.rate}}折</p>
                </div>
                <buttons :id="idx.gameid"/>
                </li>
            </ul>
            </div>
            <router-link v-if="item.indextype==='indexactivity'"  :to="`/detail/${item.data.adurl}`"><img :src="item.data.imgurl" class="f-w100"></router-link>
        </li>
        <div v-if="!isCate">
            <h3 class="f-tal">更多推荐</h3>
            <li v-for="(idx,ind) in recommend" :key="ind" class="f-dfc list">
            <img :src="idx.micon" class="bg">
            <div class="f-fx1">
                <p>{{idx.gamename}}</p>
                <p class="f-666 f-fs12">{{idx.typename}}｜{{idx.adsize}}</p>
                <p class="f-e85 f-fs12">首充{{idx.ad_min_rate}}折</p>
            </div>
            <buttons :id="idx.gameid"/>
            </li>
        </div>
    </ul>
</template>

<script>
export default {
    name: '',

    data () {
        return {
            list:[],
            recommend:[],
            page:0,
            isCate:true,
            loading:false
        }
    },
    methods: {
        link(id){
            this.$router.push(`/detail/${id}`);
        },
        loadMore(){
            this.loading = true;
            if(this.isCate){
                this.$ajax.Index.list(++this.page).then(({data:{data:{indextypegamelist}}})=>{
                this.loading = false;
                if(indextypegamelist){
                    //console.log(indextypegamelist)
                    this.list.push(...indextypegamelist);
                }else{
                    this.isCate=false;
                    this.page=0;
                }
                })
            }else{
                this.$ajax.Index.listMore(++this.page).then(({data:{data:{gamelist}}})=>{
                if(gamelist){
                    this.recommend.push(...gamelist);
                    //this.reloading = false;
                    this.loading = false;
                }else{
                    this.loading = true;
                    this.$toast('没有更多')
                }
                })
                //this.$toast('没有更多')
            }
            }
    },

    created (){}
}
</script>

<style scoped>

</style>
